package api.homework.one;

import java.util.concurrent.Callable;

/**
 * @author lwj
 * @date 2025-03-10
 * @vesion 1.0.0
 */
public class SumCallable implements Callable<Integer> {
    /**
     * 起始数
     */
    private int num;
    /**
     * 循环的次数
     */
    private int totalNum;

    // 构造方法
    public SumCallable() {}
    public SumCallable(int num,int totalNum) {
        this.num = num;
        this.totalNum = totalNum;
    }

    @Override
    public Integer call() throws Exception {
        Integer count = 0;
        for (int i = num; i <= totalNum; i++) {
            count += i;
        }
        return count;
    }
}
